let $timerBtn = (function(){
  console.log('timerbtn');
  let $btn = $('<input type="button" class="timer-button">'),
    cfg = {
      comtainer: 'body',
      title: '同意',
      delay: 6,
      enabled: false,
      onClick: null
    },
      delay = 6,
      timer = null;

$btn.css({
  height: '50px',
  width:'150px',
  'font-size': '1.2em'
});
function show(config){
  console.log('show');
   $.extend(cfg, config);
  $(cfg.container).append($btn);

  $btn.val(cfg.title+'（' + cfg.delay + 's）');
  $btn.attr('disabled', 'disabled');

  timer = setInterval(()=>{
    $btn.val(cfg.title+'（' + --cfg.delay + 's）');
    if(cfg.delay === 0){
      clearInterval(timer);
      $btn.val(cfg.title);
      $btn.removeAttr('disabled');
    }
  }, 1000);

  $btn.click(() => {
    alert(cfg.onClick);
  })
}

function destory() {
  $btn.remove();
}

  return  { show, destory };

})();
